package router

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"mxshop/mxshop_api/goods_web/api/goods"
	"mxshop/mxshop_api/goods_web/middlewares"
)

func InitGoodsRouter(Router *gin.RouterGroup) {
	GoodsRouter := Router.Group("goods")
	zap.S().Info("配置用户相关url")
	{
		GoodsRouter.GET("", goods.List) //列表
		GoodsRouter.POST("", middlewares.JWTAuth(),
			middlewares.IsAdminAuth(), goods.New) //新建
		GoodsRouter.GET("/:id", goods.Detail) //详情
		GoodsRouter.DELETE("/:id", middlewares.JWTAuth(),
			middlewares.IsAdminAuth(), goods.Delete) //删除
		GoodsRouter.GET("/:id/stocks", goods.Stocks) //库存
		GoodsRouter.PATCH("/:id", middlewares.JWTAuth(),
			middlewares.IsAdminAuth(), goods.UpdateStatus) //更新状态,,参数错误？？？
		GoodsRouter.PUT("/:id", middlewares.JWTAuth(),
			middlewares.IsAdminAuth(), goods.Update) //更新商品
	}

}
